#include <bits/stdc++.h>
using namespace std;
const int N = 5010;

int n, s, a, b;
struct node
{
	int x, y;
}t[N];
int ans;

int main()
{
	cin >> n >> s >> a >> b;
	for(int i = 0;i < n;i ++) cin >> t[i].x >> t[i].y;
	sort(t, t + n, [](node& n1, node& n2){
		return n1.y < n2.y;
	});
	for(int i = 0;i < n;i ++)
	{
		if(a + b < t[i].x) continue;
		if(s < t[i].y) break;
		ans ++;
		s -= t[i].y;
	}
	cout << ans << endl;
	return 0;
}